package aic.beans;

import java.util.UUID;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Address {

//    private static int cntId = 0;

    private String id;
    private String street;
    private String city;
    private int house;
    private int door;
    private String zip_code;

    public Address() {
//        cntId++;
//        this.id = "Address"+cntId;
        UUID uuid = UUID.randomUUID();
        this.id = uuid.toString();
    }

    @Override
    public String toString() {
        return "id: " + this.id + " / street: " + this.street + " / city: " + this.city + " / house: " + this.house + " / door: " + this.door;
    }

    @XmlElement
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @XmlElement
    public int getDoor() {
        return door;
    }

    public void setDoor(int door) {
        this.door = door;
    }

    @XmlElement
    public int getHouse() {
        return house;
    }

    public void setHouse(int house) {
        this.house = house;
    }

    @XmlAttribute
    @XmlID
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @XmlElement
    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    @XmlElement
    public String getZip_code() {
        return zip_code;
    }

    public void setZip_code(String zip_code) {
        this.zip_code = zip_code;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Address other = (Address) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        if ((this.street == null) ? (other.street != null) : !this.street.equals(other.street)) {
            return false;
        }
        if ((this.city == null) ? (other.city != null) : !this.city.equals(other.city)) {
            return false;
        }
        if (this.house != other.house) {
            return false;
        }
        if (this.door != other.door) {
            return false;
        }
        if ((this.zip_code == null) ? (other.zip_code != null) : !this.zip_code.equals(other.zip_code)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 37 * hash + (this.street != null ? this.street.hashCode() : 0);
        hash = 37 * hash + (this.city != null ? this.city.hashCode() : 0);
        hash = 37 * hash + this.house;
        hash = 37 * hash + this.door;
        hash = 37 * hash + (this.zip_code != null ? this.zip_code.hashCode() : 0);
        return hash;
    }


}
